<?php
class config_model extends CI_Model {

	public function __construct()
    {
		parent::__construct();
		$this->load->database();
    }
	
	/* Basic DB opeartion*/
    
	public function get_all()
    {
		$query = $this->db->get('config');
		return $query->result_array();
    }
  
    public function get_by_id($cfg_id)
    {
		$query = $this->db->get_where('config', array('cfg_id' => $cfg_id));
		return $query->row_array();
    }
  
    public function insert($data)
    {
		$this->db->insert('config',$data);
		return $this->db->affected_rows();
	}
	
    public function update($cfg_id,$data)
    {
		$this->db->update('config', $data, array('cfg_id' => $cfg_id));
		return $this->db->affected_rows();
    }
	
	public function delete($cfg_id)
	{
		$this->db->delete('config', array('cfg_id' => $cfg_id)); 
		return $this->db->affected_rows();
	}
	
	/*Business logic opeartion*/
	public function get_by_key($key)
	{
		$query = $this->db->get_where('config', array('cfg_key' => $key));
		return $query->row_array();
	}

}
?>
